﻿using PBDesk.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace PBDesk.Utilities.Tests
{
    
    
    /// <summary>
    ///This is a test class for MyUtilsTest and is intended
    ///to contain all MyUtilsTest Unit Tests
    ///</summary>
    [TestClass()]
    public class MyUtilsTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for MyUtils Constructor
        ///</summary>
        [TestMethod()]
        public void MyUtilsConstructorTest()
        {
            MyUtils target = new MyUtils();
            Assert.Inconclusive("TODO: Implement code to verify target");
        }



        /// <summary>
        ///A test for ParseEnum
        ///</summary>
        public void ParseEnumTestHelper<T>()
        {
            ColorSwatch actual;
            string inString = string.Empty; 
            bool ignoreCase = false; 
            bool throwException = false; 
            ColorSwatch expected = default(ColorSwatch); 

            //Test Case # 001
            inString = "Red";
            ignoreCase = true;
            throwException = false;
            expected = ColorSwatch.Red;
            
            actual = MyUtils.ParseEnum<ColorSwatch>(inString, ignoreCase, throwException);
            Assert.AreEqual(expected, actual);

            //Test Case # 002
            inString = "red";
            ignoreCase = false;
            throwException = false;
            expected = ColorSwatch.Red;

            actual = MyUtils.ParseEnum<ColorSwatch>(inString, ignoreCase, throwException);
            Assert.AreEqual(expected, actual);
           
        }

        [TestMethod()]
        public void ParseEnumTest()
        {
            ParseEnumTestHelper<GenericParameterHelper>();
        }

        /// <summary>
        ///A test for ParseEnum
        ///</summary>
        public void ParseEnumTest1Helper<T>()
        {
            //string inString = string.Empty; // TODO: Initialize to an appropriate value
            //T defaultValue = default(T); // TODO: Initialize to an appropriate value
            //bool ignoreCase = false; // TODO: Initialize to an appropriate value
            //bool throwException = false; // TODO: Initialize to an appropriate value
            //T expected = default(T); // TODO: Initialize to an appropriate value
            //T actual;
            //actual = MyUtils.ParseEnum<T>(inString, defaultValue, ignoreCase, throwException);
            //Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void ParseEnumTest1()
        {
            ParseEnumTest1Helper<ColorSwatch>();
        }





        /// <summary>
        ///A test for ParseEnum
        ///</summary>
        public void ParseEnumTest2Helper<T>()
            where T : struct
        {
            int input = 2; // TODO: Initialize to an appropriate value
            ColorSwatch defaultValue = ColorSwatch.NoColor; // TODO: Initialize to an appropriate value
            bool throwException = false; // TODO: Initialize to an appropriate value
            ColorSwatch expected = ColorSwatch.Green; // TODO: Initialize to an appropriate value
            ColorSwatch actual;
            actual = MyUtils.ParseEnum<ColorSwatch>(input, defaultValue, throwException);
            Assert.AreEqual(expected, actual);

            //Test Case # 002
            input = 0;
            expected = ColorSwatch.NoColor;
            actual = MyUtils.ParseEnum<ColorSwatch>(input, defaultValue, throwException);
            Assert.AreEqual(expected, actual);

            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        [TestMethod()]
        public void ParseEnumTest2()
        {
            ParseEnumTest2Helper<ColorSwatch>();
            Assert.Inconclusive("No appropriate type parameter is found to satisfies the type constraint(s) of T. " +
                    "Please call ParseEnumTest2Helper<T>() with appropriate type parameters.");
        }

        /// <summary>
        ///A test for GetShuffleCSV
        ///</summary>
        [TestMethod()]
        public void GetShuffleTest()
        {
            
            int size = 0; 
            int startValue = 0; 
            string expected = string.Empty; 
            string actual;

            //Case-1
            size = 7;
            startValue = 0;
            actual = MyUtils.GetShuffleCSV(size, startValue);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
    }

    internal enum ColorSwatch
    {
        NoColor = -1,
        Red = 20,
        Green = 2,
        Blue = 3,
        Yellow = 4,
        Orange = 5,
        Pink = 6,
        Black = 10,
    }
}
